class list:
    def __init__(self,*args):
        self.l=(1,2,3)
        self.length=len(args)

    def append(self,num):
        self.l.append(4)
        self.length+=1

    def __len__(self):
        # return self.length
        n=0
        for i in self.l:
            n+=1
        return n

l=[1,2,3]
l.append(4)
# len(l)
def len(obj):
    return obj.__len__()

print(dir(list))

# 所有实现了__len__方法的类,在调用len函数的时候,obj都说是鸭子类型
# 迭代器协议 __iter__ __next__ 是迭代器